/*
using MyGeneration/Template/NHibernate (c) by Sharp 1.4
based on OHM (alvy77@hotmail.com)
*/
using System;
using System.Collections;
using System.Collections.Generic;

namespace DomainModel
{

	/// <summary>
	/// IRole interface for NHibernate mapped table 'Role'.
	/// </summary>
	public interface IRole
	{
		#region Public Properties
		
		int R_id
		{
			get ;
			set ;
			  
		}
		
		string R_Name
		{
			get ;
			set ;
			  
		}
		
		string R_Desc
		{
			get ;
			set ;
			  
		}
		
		string R_SectionCodeList
		{
			get ;
			set ;
			  
		}
		
		int R_oid
		{
			get ;
			set ;
			  
		}
		
		DateTime R_addTime
		{
			get ;
			set ;
			  
		}
		
		int? R_lastOid
		{
			get ;
			set ;
			  
		}
		
		DateTime? R_lastTime
		{
			get ;
			set ;
			  
		}
		
		bool IsDeleted { get; set; }
		bool IsChanged { get; set; }
		
		#endregion 
	}

	/// <summary>
	/// Role object for NHibernate mapped table 'Role'.
	/// </summary>
	[Serializable]
	public class Role : ICloneable,IRole
	{
		#region Member Variables

		protected int _r_id;
		protected string _r_name;
		protected string _r_desc;
		protected string _r_sectioncodelist;
		protected int _r_oid;
		protected DateTime _r_addtime;
		protected int? _r_lastoid;
		protected DateTime? _r_lasttime;
		protected bool _bIsDeleted;
		protected bool _bIsChanged;
		#endregion
		
		#region Constructors
		public Role() {}
		
		public Role(string pRName, string pRDesc, string pRSectionCodeList, int pRoid, DateTime pRaddTime, int? pRlastOid, DateTime? pRlastTime)
		{
			this._r_name = pRName; 
			this._r_desc = pRDesc; 
			this._r_sectioncodelist = pRSectionCodeList; 
			this._r_oid = pRoid; 
			this._r_addtime = pRaddTime; 
			this._r_lastoid = pRlastOid; 
			this._r_lasttime = pRlastTime; 
		}
		
		public Role(string pRName, string pRSectionCodeList, int pRoid, DateTime pRaddTime)
		{
			this._r_name = pRName; 
			this._r_sectioncodelist = pRSectionCodeList; 
			this._r_oid = pRoid; 
			this._r_addtime = pRaddTime; 
		}
		
		public Role(int pRid)
		{
			this._r_id = pRid; 
		}
		
		#endregion
		
		#region Public Properties
		
		public virtual int R_id
		{
			get { return _r_id; }
			set { _bIsChanged |= (_r_id != value); _r_id = value; }
			
		}
		
		public virtual string R_Name
		{
			get { return _r_name; }
			set 
			{
			  if (value != null && value.Length > 200)
			    throw new ArgumentOutOfRangeException("R_Name", "R_Name value, cannot contain more than 200 characters");
			  _bIsChanged |= (_r_name != value); 
			  _r_name = value; 
			}
			
		}
		
		public virtual string R_Desc
		{
			get { return _r_desc; }
			set 
			{
			  if (value != null && value.Length > 500)
			    throw new ArgumentOutOfRangeException("R_Desc", "R_Desc value, cannot contain more than 500 characters");
			  _bIsChanged |= (_r_desc != value); 
			  _r_desc = value; 
			}
			
		}
		
		public virtual string R_SectionCodeList
		{
			get { return _r_sectioncodelist; }
			set 
			{
			  if (value != null && value.Length > 2000)
			    throw new ArgumentOutOfRangeException("R_SectionCodeList", "R_SectionCodeList value, cannot contain more than 2000 characters");
			  _bIsChanged |= (_r_sectioncodelist != value); 
			  _r_sectioncodelist = value; 
			}
			
		}
		
		public virtual int R_oid
		{
			get { return _r_oid; }
			set { _bIsChanged |= (_r_oid != value); _r_oid = value; }
			
		}
		
		public virtual DateTime R_addTime
		{
			get { return _r_addtime; }
			set { _bIsChanged |= (_r_addtime != value); _r_addtime = value; }
			
		}
		
		public virtual int? R_lastOid
		{
			get { return _r_lastoid; }
			set { _bIsChanged |= (_r_lastoid != value); _r_lastoid = value; }
			
		}
		
		public virtual DateTime? R_lastTime
		{
			get { return _r_lasttime; }
			set { _bIsChanged |= (_r_lasttime != value); _r_lasttime = value; }
			
		}
		

		public virtual bool IsDeleted
		{
			get
			{
				return _bIsDeleted;
			}
			set
			{
				_bIsDeleted = value;
			}
		}
		
		public virtual bool IsChanged
		{
			get
			{
				return _bIsChanged;
			}
			set
			{
				_bIsChanged = value;
			}
		}
		
		#endregion 
		
		#region Equals And HashCode Overrides
		/// <summary>
		/// local implementation of Equals based on unique value members
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			Role castObj = null;
			try
			{
				castObj = (Role)obj;
			} catch(Exception) { return false; } 
			return ( castObj != null ) &&
				( this._r_id == castObj.R_id );
		}
		/// <summary>
		/// local implementation of GetHashCode based on unique value members
		/// </summary>
		public override int GetHashCode()
		{
		  
			
			int hash = 57; 
			hash = 27 * hash * _r_id.GetHashCode();
			return hash; 
		}
		#endregion
		
		#region ICloneable methods
		
		public virtual object Clone()
		{
			return this.MemberwiseClone();
		}
		
		#endregion
	}
	
	#region Custom ICollection interface for Role 

	
	public interface IRoleCollection : ICollection
	{
		Role this[int index]{	get; set; }
		void Add(Role pRole);
		void Clear();
	}
	
	[Serializable]
	public class RoleCollection : IRoleCollection
	{
		private IList<Role> _arrayInternal;

		public RoleCollection()
		{
			_arrayInternal = new List<Role>();
		}
		
		public RoleCollection( IList<Role> pSource )
		{
			_arrayInternal = pSource;
			if(_arrayInternal == null)
			{
				_arrayInternal = new List<Role>();
			}
		}

		public Role this[int index]
		{
			get
			{
				return _arrayInternal[index];
			}
			set
			{
				_arrayInternal[index] = value;
			}
		}

		public int Count { get { return _arrayInternal.Count; } }
		public bool IsSynchronized { get { return false; } }
		public object SyncRoot { get { return _arrayInternal; } }
		public void CopyTo(Array array, int index){ _arrayInternal.CopyTo((Role[])array, index); }
		public IEnumerator GetEnumerator() { return _arrayInternal.GetEnumerator(); }
		public void Add(Role pRole) { _arrayInternal.Add(pRole); }
		public void Clear() { _arrayInternal.Clear(); }
		public IList<Role> GetList() { return _arrayInternal; }
	 }
	
	#endregion
}
